<?php
// aqui o que precisa para funcionar o image crud
$this->load->view("manager/includes/white_page_init");
?>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/plugins/uploadify-v3.1/uploadify.css">
<script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/uploadify-v3.1/jquery.uploadify-3.1.min.js"></script>

<style>
    #file_upload{
        float: left;
    }
</style>

<form method="post" enctype="multipart/form-data">
    <input type="file" name="Filedata" id="file_upload" />

    <div style="float: left; width: 400px; padding-left: 15px;">
        Arquivos válidos: <b>jpg, png, gif</b><br/>
        * Clique duplo na imagem para usá-la / selecioná-la..
    </div>    
</form>

<script>

    // cria o uploader multiplo
    $(function() {
        $('#file_upload').uploadify({
            'swf': '<?php echo base_url(); ?>assets/plugins/uploadify-v3.1/uploadify.swf',
            'uploader': '<?php echo(base_url() . "manager/internal/editordoupload"); ?>',
            'fileSizeLimit': '10024KB',
            'formData': {'uploadfolder': '<?php echo($uploadfolder); ?>'},
            'progressData': 'speed',
            'fileTypeExts': '*.gif; *.jpg; *.png',
            'onUploadSuccess': function(file, data, response) {

            },
            'onQueueComplete': function(queueData) {
                window.location.href = '<?php echo(base_url() . "manager/internal/ckeditorupload"); ?>';
            }
        });
    });



    function setUrlToParentFiled(elem) {
        var v = $(window.opener.document).find('.cke_dialog_ui_input_text input');
        v.first().val(elem.src);
        window.close();
    }

</script>



<div style="clear: both">
    <hr/>

    <?php
    $folder = $this->config->item("local_disk_url") . $uploadfolder;
    $d = dir($folder);
    while (false !== ($entry = $d->read())) {
        $este = $folder . "/" . $entry;
        $inf = pathinfo($este);

        if ($inf['extension'] == 'jpg' or $inf['extension'] == 'png' or $inf['extension'] == 'gif') {
            $figura = base_url() . $uploadfolder . "/" . $entry;
            ?>
            <div style="float: left; margin: 10px">
                <img ondblclick="setUrlToParentFiled(this)" src="<?php echo($figura); ?>" style="max-width: 256px; max-height: 256px" />
            </div>
            <?php
        }
    }
    $d->close();
    ?>

</div>

<?php
// fim de página padrao
$this->load->view("manager/includes/white_page_end");
?>
